<?php
/**
 * Class return connection to database
 *
 * @author: http://phpdao.com
 * @date: 27.11.2007
 * 
 * @Edit: Changed for Sqlite 
 * @author: Dragan Milchevski
 * @data: 23.06.2012
 */

class ConnectionFactory{
	
	/**
	 * Connect to the database and return the connection
	 *
	 * @return PDO object
	 */
	static public function getConnection(){
		try {
			$dbHandle = new PDO('sqlite:'.ConnectionProperty::$database_path.ConnectionProperty::$database_name.'.sq3');
			
		} catch (PDOException $e) {
			print "Error: ".$e->getMessage()."<br/>";
			print "PHP extensions PDO and PDO_SQLite must be installed!";
			die();
		}
		//echo "<br>connected to ".ConnectionProperty::$database_name."<br>";
		return $dbHandle;
	}

	/**
	 * Close the database connection
	 *
	 * @param connection
	 */
	static public function close($connection){
		//echo "connection closed<br>";
		$connection = null;
	}
}
?>